<?php
require_once ('./class/H.class.php');
require_once ('./class/database.class.php');
_split();
function _split($p = 1,$pageSz = 50){
    $regx = "~\d{1,2}、[\s\S]*?([\s\S]*?)。~";
    global $dbm;
    //cid=1  唯美，cid=2  哲理，cid=3  爱情，cid=4  励志，cid=5  经典，cid=6  心碎，cid=7  心烦，cid=8  暗恋，cid=9  失望，cid=10 友情 
    //cid=11 想你，cid=12 骂人，cid=13 抒情，cid=14 优美，cid=15 搞笑，cid=16 心酸，cid=17 心累，cid=18 失恋，cid=19 无奈，cid=20 想家
    //cid=21 诗意，cid=22 伤感，cid=23 亲情，cid=24 心痛，cid=25 心静，cid=26 表白，cid=27 难过，cid=28 思念，cid=29 现实，cid=30 回忆
    //cid=31 正能量，cid=32 个性签名， cid=33 经典广告语，cid=34 经典台词，cid=35 佛家经典禅语，cid=36 口号大全
    $listData = $dbm->select('tb_link_lists',['id','title','cid','content'],['content[!]'=>"",'cid'=>36,"ORDER"=>['id'=>"ASC"],'LIMIT' => [($p-1)*$pageSz,$pageSz]]);
    if(count($listData) == 0){
        echo "already completes...".chr(10);
        return;
    }
    foreach($listData as $k => $v){
        //分割
        $itemS = preg_split("~\d{1,2}、~",str_replace("\n","",$v['content']));
       // preg_match_all($regx,str_replace("\n","",$v['content']),$m);
        if(!empty($itemS)){
            foreach($itemS as $mk => $mv){
                $dbm->insert('tb_content',[
                    'ptype' => $v['cid'],
                    'type' => $v['id'],
                    'desc' => str_replace('cads();',"",trim($mv)),
                    'source' => 1,
                    'ctime' => time(),
                    'xclass' => "-",
                    ]
                );
                echo $v['id']."-success-".chr(10);
            }
        }
    }
    sleep(1);
    _split($p + 1,$pageSz);
}
